package com.alibaba.shopping_cart_service.listener;

import com.alibaba.shopping_common.service.CartService;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName DelCartListener
 * @Description 监听下架商品的消息
 * @Author Leo
 * @Date 2024/12/18 14:41
 */
@Service
@RocketMQMessageListener(topic = "del_cart_queue",consumerGroup = "del_cart_group")
public class DelCartListener implements RocketMQListener<Long> {

    @Autowired
    private CartService cartService;

    @Override
    public void onMessage(Long aLong) {
        // 消费消息，删除Redis中被下架的商品数据
        System.out.println("删除Redis中被下架的商品数据");
        cartService.deleteRedisCartGoods(aLong);
    }
}




